package com.atguigu.eduservice.service.impl;

import com.atguigu.eduservice.entity.EduComment;
import com.atguigu.eduservice.mapper.EduCommentMapper;
import com.atguigu.eduservice.service.EduCommentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 评论 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2021-05-12
 */
@Service
public class EduCommentServiceImpl extends ServiceImpl<EduCommentMapper, EduComment> implements EduCommentService {
    //删除评论
    @Override
    public boolean deleteById(String commentId, String userId) {
        QueryWrapper<EduComment> wrapper=new QueryWrapper<>();
        wrapper.eq("id",commentId);
        wrapper.eq("member_id",userId);
        return this.remove(wrapper);
    }
    //判断是否是该用户的评论
    @Override
    public boolean isComment(String commentId, String userId) {
        QueryWrapper<EduComment> wrapper=new QueryWrapper<>();
        wrapper.eq("id",commentId);
        wrapper.eq("member_id",userId);
        return baseMapper.selectCount(wrapper)>0;
    }
}
